<template>
  <div class="info">
    <a-avatar :size="50" :src="getFile(authorInfo.avatar)" @click="redirectAcademic(authorInfo.upId)"/>
    <div class="bar">
      <div class="name">{{ authorInfo.createByName }}</div>
      <div class="font" v-if="authorInfo.specialty">[{{ authorInfo.specialty }}]领域博主</div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import {getByUserId} from "@/api/academic";
import router from "@/router";
import {usePortalStore} from "@/store/portal";

const portalStore = usePortalStore()
const props = defineProps({
  authorInfo: {
    type: Object,
    default: {}
  }
})

async function redirectAcademic(userId) {
  const data: any = await getByUserId(userId)
  if (data.result) {
    const url = router.resolve({
      path: `/portal/${data.result.netAddress}`
    });
    portalStore.setPortalData("")
    window.open(url.href, "_blank");
  }
}
</script>
<style lang="css" scoped>
.info {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.bar {
  margin-left: 10px;
  text-align: left;
}

.name {
  font-size: 14px;
  font-weight: 500;
}

.font {
  font-size: 12px;
}
</style>
